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

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

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

n = A("n")
b = B("b")
m = C("m")
l = B("l")
d = B("d")

n.u = m
n.t = d
b.r = n
m.v = d
m.s = n
l.r = n
d.r = n
assert d.r.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: B = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
m = C("m")
l = B("l")
d = B("d")

n.u = m
n.t = d
b.r = n
m.v = d
m.s = n
l.r = n
d.r = n
assert d.r.u.v.txt == "d"