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

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

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

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

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

g.q = b
g.y = c
b.w = g
c.t = b
c.p = j
j.z = i
i.z = j
k.t = b
k.p = j
assert i.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: C = None
        self.txt = txt

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

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

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

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

g.q = b
g.y = c
b.w = g
c.t = b
c.p = j
j.z = i
i.z = j
k.t = b
k.p = j
assert i.z.z.z.z.z.z.txt == "i"