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

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

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

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

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

c.o = n
c.u = f
d.u = f
d.t = c
f.w = n
f.r = c
n.z = d
n.v = f
n.u = c
n.p = c
assert f.r.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

c.o = n
c.u = f
d.u = f
d.t = c
f.w = n
f.r = c
n.z = d
n.v = f
n.u = c
n.p = c
assert f.r.u.r.txt == "c"