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

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

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

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

f = A("f")
e = B("e")
c = C("c")
n = D("n")

f.w = e
f.y = e
f.t = c
e.t = c
c.t = e
c.z = e
c.y = n
c.r = f
n.x = f
assert e.t.y.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.t: C = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
c = C("c")
n = D("n")

f.w = e
f.y = e
f.t = c
e.t = c
c.t = e
c.z = e
c.y = n
c.r = f
n.x = f
assert e.t.y.x.t.txt == "c"