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

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

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

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

l = A("l")
b = B("b")
h = C("h")
f = D("f")
j = B("j")
m = D("m")

l.x = j
b.r = f
b.x = m
b.o = j
h.u = j
h.s = b
f.t = m
f.z = j
j.r = m
j.x = m
j.o = b
m.t = f
m.z = b
assert h.s.x.t.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

l = A("l")
b = B("b")
h = C("h")
f = D("f")
j = B("j")
m = D("m")

l.x = j
b.r = f
b.x = m
b.o = j
h.u = j
h.s = b
f.t = m
f.z = j
j.r = m
j.x = m
j.o = b
m.t = f
m.z = b
assert h.s.x.t.z.x.txt == "m"