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

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

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

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

a = A("a")
b = B("b")
f = C("f")
n = D("n")

a.r = b
a.t = b
b.x = f
b.y = n
b.w = a
b.u = a
f.x = b
f.u = b
f.y = a
n.y = a
n.u = f
n.t = b
assert b.x.u.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: B = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
f = C("f")
n = D("n")

a.r = b
a.t = b
b.x = f
b.y = n
b.w = a
b.u = a
f.x = b
f.u = b
f.y = a
n.y = a
n.u = f
n.t = b
assert b.x.u.u.r.txt == "b"