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

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

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

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

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

n.q = b
n.t = h
n.x = h
l.r = h
h.w = j
h.r = l
b.t = h
b.x = h
b.u = l
j.q = b
j.t = h
j.x = h
assert l.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: C = None
        self.x: C = None
        self.txt = txt

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

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

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

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

n.q = b
n.t = h
n.x = h
l.r = h
h.w = j
h.r = l
b.t = h
b.x = h
b.u = l
j.q = b
j.t = h
j.x = h
assert l.r.r.r.r.txt == "l"