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

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

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

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

h = A("h")
e = B("e")
l = C("l")
n = D("n")
d = A("d")
c = B("c")
b = D("b")
k = A("k")
m = C("m")

h.q = m
e.u = n
l.r = m
n.x = b
n.u = b
n.v = l
d.q = m
c.u = n
b.x = n
b.u = n
b.v = m
k.q = m
m.r = l
assert b.x.v.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

h = A("h")
e = B("e")
l = C("l")
n = D("n")
d = A("d")
c = B("c")
b = D("b")
k = A("k")
m = C("m")

h.q = m
e.u = n
l.r = m
n.x = b
n.u = b
n.v = l
d.q = m
c.u = n
b.x = n
b.u = n
b.v = m
k.q = m
m.r = l
assert b.x.v.r.r.txt == "l"