class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: C = None
        self.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

i = A("i")
k = B("k")
g = C("g")
e = D("e")
j = A("j")
c = D("c")
a = C("a")
m = B("m")
f = D("f")
n = B("n")

i.u = j
i.w = a
k.z = i
k.t = a
k.u = j
g.r = a
e.v = g
j.u = i
j.w = a
c.v = g
a.r = g
m.z = j
m.t = g
m.u = i
f.v = a
n.z = i
n.u = i
n.t = g
assert k.t.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: C = None
        self.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

i = A("i")
k = B("k")
g = C("g")
e = D("e")
j = A("j")
c = D("c")
a = C("a")
m = B("m")
f = D("f")
n = B("n")

i.u = j
i.w = a
k.z = i
k.t = a
k.u = j
g.r = a
e.v = g
j.u = i
j.w = a
c.v = g
a.r = g
m.z = j
m.t = g
m.u = i
f.v = a
n.z = i
n.u = i
n.t = g
assert k.t.r.r.r.r.r.txt == "g"