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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
m = C("m")
h = D("h")
c = D("c")

b.u = c
b.r = c
k.v = h
m.r = h
h.p = c
c.p = h
assert h.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
m = C("m")
h = D("h")
c = D("c")

b.u = c
b.r = c
k.v = h
m.r = h
h.p = c
c.p = h
assert h.p.p.p.p.p.txt == "c"