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

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

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

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

a = A("a")
f = B("f")
e = C("e")
j = D("j")

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

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

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

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

a = A("a")
f = B("f")
e = C("e")
j = D("j")

a.t = f
a.z = f
a.x = f
a.p = e
f.v = e
f.s = e
e.p = j
e.q = a
e.x = a
e.v = f
j.r = f
j.q = e
assert f.v.p.q.txt == "e"