class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.y: A = None
        self.t: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: D = None
        self.o: B = None
        self.txt = txt

k = A("k")
m = B("m")
g = C("g")
j = D("j")
b = C("b")
a = C("a")
l = A("l")
e = D("e")
i = D("i")

k.x = l
m.x = k
g.r = k
g.o = l
g.y = l
g.t = m
j.v = a
j.x = e
j.o = m
b.r = k
b.y = k
b.o = l
b.t = m
a.r = l
a.y = l
a.o = k
a.t = m
l.x = k
e.v = g
e.x = i
e.o = m
i.v = g
i.x = j
i.o = m
assert g.r.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.y: A = None
        self.t: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: D = None
        self.o: B = None
        self.txt = txt

k = A("k")
m = B("m")
g = C("g")
j = D("j")
b = C("b")
a = C("a")
l = A("l")
e = D("e")
i = D("i")

k.x = l
m.x = k
g.r = k
g.o = l
g.y = l
g.t = m
j.v = a
j.x = e
j.o = m
b.r = k
b.y = k
b.o = l
b.t = m
a.r = l
a.y = l
a.o = k
a.t = m
l.x = k
e.v = g
e.x = i
e.o = m
i.v = g
i.x = j
i.o = m
assert g.r.x.x.x.x.txt == "k"