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

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

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

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

g = A("g")
i = B("i")
c = C("c")
d = D("d")
j = A("j")

g.u = c
i.t = j
i.r = c
c.o = j
d.z = i
j.u = c
assert c.o.u.o.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
c = C("c")
d = D("d")
j = A("j")

g.u = c
i.t = j
i.r = c
c.o = j
d.z = i
j.u = c
assert c.o.u.o.u.o.txt == "j"