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

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

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

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

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

j.t = f
j.v = b
j.u = b
j.q = i
i.p = f
i.x = b
f.z = i
f.r = j
f.t = j
f.q = b
b.x = c
b.s = c
c.p = f
c.x = b
assert j.t.q.x.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.v: D = None
        self.q: B = None
        self.u: D = None
        self.txt = txt

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

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

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

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

j.t = f
j.v = b
j.u = b
j.q = i
i.p = f
i.x = b
f.z = i
f.r = j
f.t = j
f.q = b
b.x = c
b.s = c
c.p = f
c.x = b
assert j.t.q.x.x.s.txt == "c"