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

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

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

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

l = A("l")
j = B("j")
k = C("k")
d = D("d")
e = C("e")
i = B("i")
f = B("f")
n = B("n")
h = D("h")
b = B("b")

l.r = k
j.w = b
k.r = b
d.x = i
d.t = h
d.u = k
d.z = k
e.r = f
i.w = n
f.w = j
n.w = j
h.x = f
h.t = d
h.u = k
h.z = k
b.w = f
assert i.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

l = A("l")
j = B("j")
k = C("k")
d = D("d")
e = C("e")
i = B("i")
f = B("f")
n = B("n")
h = D("h")
b = B("b")

l.r = k
j.w = b
k.r = b
d.x = i
d.t = h
d.u = k
d.z = k
e.r = f
i.w = n
f.w = j
n.w = j
h.x = f
h.t = d
h.u = k
h.z = k
b.w = f
assert i.w.w.w.w.txt == "f"