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

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

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

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

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

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

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

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

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

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

l.p = n
n.v = h
n.p = b
b.t = n
b.u = n
b.x = n
b.v = l
h.u = l
h.r = n
h.x = n
h.w = n
assert n.p.u.p.txt == "b"