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

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

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

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

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

k.t = b
l.y = f
d.t = k
d.y = e
d.r = e
h.w = b
h.u = d
h.y = e
h.r = l
f.y = l
e.t = b
e.y = d
e.r = d
b.t = k
m.w = k
m.u = e
m.y = e
m.r = f
assert f.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

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

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

k.t = b
l.y = f
d.t = k
d.y = e
d.r = e
h.w = b
h.u = d
h.y = e
h.r = l
f.y = l
e.t = b
e.y = d
e.r = d
b.t = k
m.w = k
m.u = e
m.y = e
m.r = f
assert f.y.y.y.y.y.y.txt == "f"