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

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

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

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

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

g.t = b
g.w = c
g.z = k
g.p = e
e.z = g
k.v = c
k.o = c
k.q = b
k.s = b
b.p = k
c.v = k
c.o = k
c.q = b
c.s = b
assert g.w.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.w: C = None
        self.z: C = None
        self.p: B = None
        self.txt = txt

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

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

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

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

g.t = b
g.w = c
g.z = k
g.p = e
e.z = g
k.v = c
k.o = c
k.q = b
k.s = b
b.p = k
c.v = k
c.o = k
c.q = b
c.s = b
assert g.w.o.o.txt == "c"