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

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

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

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

l = A("l")
e = B("e")
h = C("h")
a = D("a")
b = C("b")
n = A("n")

l.x = b
l.r = e
e.x = h
h.u = b
a.v = l
b.u = h
n.x = b
n.r = e
assert h.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: B = None
        self.txt = txt

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

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

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

l = A("l")
e = B("e")
h = C("h")
a = D("a")
b = C("b")
n = A("n")

l.x = b
l.r = e
e.x = h
h.u = b
a.v = l
b.u = h
n.x = b
n.r = e
assert h.u.u.u.u.txt == "h"