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

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

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

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

e = A("e")
b = B("b")
f = C("f")
g = D("g")
c = B("c")

e.s = f
e.t = f
b.z = e
f.v = b
f.q = b
f.w = b
f.y = e
g.r = e
g.t = e
g.v = b
g.q = f
c.z = e
assert e.s.w.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: C = None
        self.txt = txt

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

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

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

e = A("e")
b = B("b")
f = C("f")
g = D("g")
c = B("c")

e.s = f
e.t = f
b.z = e
f.v = b
f.q = b
f.w = b
f.y = e
g.r = e
g.t = e
g.v = b
g.q = f
c.z = e
assert e.s.w.z.t.txt == "f"