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

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

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

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

m = A("m")
l = B("l")
d = C("d")
b = D("b")
k = B("k")
f = B("f")

m.r = k
m.x = l
l.z = k
l.t = b
l.u = f
d.x = b
d.o = b
d.q = m
d.v = m
b.z = l
b.u = l
b.w = m
b.p = m
k.z = f
k.t = b
k.u = l
f.z = l
f.t = b
f.u = k
assert m.x.u.u.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: B = None
        self.txt = txt

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

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

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

m = A("m")
l = B("l")
d = C("d")
b = D("b")
k = B("k")
f = B("f")

m.r = k
m.x = l
l.z = k
l.t = b
l.u = f
d.x = b
d.o = b
d.q = m
d.v = m
b.z = l
b.u = l
b.w = m
b.p = m
k.z = f
k.t = b
k.u = l
f.z = l
f.t = b
f.u = k
assert m.x.u.u.z.z.txt == "l"