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

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

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

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

g = A("g")
c = B("c")
k = C("k")
d = D("d")

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

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

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

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

g = A("g")
c = B("c")
k = C("k")
d = D("d")

g.r = k
g.t = k
g.q = c
g.u = d
c.s = k
c.v = d
k.u = c
k.o = c
k.z = c
d.r = c
d.q = g
d.p = k
assert c.s.z.v.txt == "d"