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

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

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

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

b = A("b")
d = B("d")
k = C("k")
e = D("e")
j = B("j")

b.x = k
d.q = b
d.y = b
d.u = e
d.t = e
k.v = b
e.w = k
e.z = j
j.q = b
j.y = b
j.u = e
j.t = e
assert j.y.x.v.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

b = A("b")
d = B("d")
k = C("k")
e = D("e")
j = B("j")

b.x = k
d.q = b
d.y = b
d.u = e
d.t = e
k.v = b
e.w = k
e.z = j
j.q = b
j.y = b
j.u = e
j.t = e
assert j.y.x.v.x.v.txt == "b"