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

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

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

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

j = A("j")
m = B("m")
l = C("l")
c = D("c")
g = D("g")
f = D("f")
k = C("k")
h = A("h")
b = B("b")
e = D("e")

j.u = g
j.r = m
j.t = h
m.o = j
m.x = b
l.z = f
c.r = m
c.y = l
c.t = l
c.w = b
g.r = b
g.w = b
g.y = l
g.t = k
f.r = b
f.w = b
f.y = l
f.t = l
k.z = g
h.u = g
h.r = m
h.t = j
b.o = h
b.x = m
e.r = m
e.y = k
e.t = k
e.w = b
assert g.y.z.t.z.t.z.t.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: B = None
        self.t: A = None
        self.txt = txt

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

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

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

j = A("j")
m = B("m")
l = C("l")
c = D("c")
g = D("g")
f = D("f")
k = C("k")
h = A("h")
b = B("b")
e = D("e")

j.u = g
j.r = m
j.t = h
m.o = j
m.x = b
l.z = f
c.r = m
c.y = l
c.t = l
c.w = b
g.r = b
g.w = b
g.y = l
g.t = k
f.r = b
f.w = b
f.y = l
f.t = l
k.z = g
h.u = g
h.r = m
h.t = j
b.o = h
b.x = m
e.r = m
e.y = k
e.t = k
e.w = b
assert g.y.z.t.z.t.z.t.z.t.z.txt == "f"