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

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

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

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

f = A("f")
g = B("g")
e = C("e")
j = D("j")
l = A("l")

f.t = l
f.q = g
f.x = e
f.z = e
g.q = j
e.r = g
e.u = j
j.y = f
j.p = e
l.t = f
l.q = g
l.x = e
l.z = e
assert j.p.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: B = None
        self.x: C = None
        self.z: C = None
        self.txt = txt

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

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

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

f = A("f")
g = B("g")
e = C("e")
j = D("j")
l = A("l")

f.t = l
f.q = g
f.x = e
f.z = e
g.q = j
e.r = g
e.u = j
j.y = f
j.p = e
l.t = f
l.q = g
l.x = e
l.z = e
assert j.p.u.y.txt == "f"