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

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

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

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

l = A("l")
h = B("h")
k = C("k")
i = D("i")
f = B("f")
c = A("c")
m = B("m")
a = D("a")
d = D("d")
g = A("g")

l.z = g
h.u = i
k.z = i
k.o = d
k.r = a
k.x = l
i.q = l
i.r = h
f.u = d
c.z = g
m.u = a
a.q = c
a.r = f
d.q = c
d.r = m
g.z = l
assert i.r.u.r.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

l = A("l")
h = B("h")
k = C("k")
i = D("i")
f = B("f")
c = A("c")
m = B("m")
a = D("a")
d = D("d")
g = A("g")

l.z = g
h.u = i
k.z = i
k.o = d
k.r = a
k.x = l
i.q = l
i.r = h
f.u = d
c.z = g
m.u = a
a.q = c
a.r = f
d.q = c
d.r = m
g.z = l
assert i.r.u.r.u.r.u.txt == "i"