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

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

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

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

a = A("a")
l = B("l")
b = C("b")
j = D("j")
m = D("m")
h = B("h")
f = D("f")
i = C("i")

a.r = f
a.s = j
a.y = j
a.u = l
l.w = h
l.s = a
b.t = a
j.p = f
m.p = j
h.w = l
h.s = a
f.p = m
i.t = a
assert f.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.s: D = None
        self.y: D = None
        self.u: B = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
b = C("b")
j = D("j")
m = D("m")
h = B("h")
f = D("f")
i = C("i")

a.r = f
a.s = j
a.y = j
a.u = l
l.w = h
l.s = a
b.t = a
j.p = f
m.p = j
h.w = l
h.s = a
f.p = m
i.t = a
assert f.p.p.p.p.p.p.p.p.txt == "j"