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

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

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

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

l = A("l")
k = B("k")
j = C("j")
i = D("i")
n = C("n")
b = A("b")
h = D("h")

l.u = k
k.x = b
k.o = i
j.t = k
j.u = n
i.q = j
n.t = k
n.u = j
b.u = k
h.q = n
assert b.u.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
j = C("j")
i = D("i")
n = C("n")
b = A("b")
h = D("h")

l.u = k
k.x = b
k.o = i
j.t = k
j.u = n
i.q = j
n.t = k
n.u = j
b.u = k
h.q = n
assert b.u.x.u.x.txt == "b"