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

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

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

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

e = A("e")
n = B("n")
f = C("f")
h = D("h")
a = C("a")
m = D("m")
l = A("l")
i = D("i")
b = C("b")
g = A("g")

e.r = n
n.r = f
n.q = a
f.p = b
h.y = m
a.p = b
m.y = i
l.r = n
i.y = m
b.p = f
g.r = n
assert i.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

e = A("e")
n = B("n")
f = C("f")
h = D("h")
a = C("a")
m = D("m")
l = A("l")
i = D("i")
b = C("b")
g = A("g")

e.r = n
n.r = f
n.q = a
f.p = b
h.y = m
a.p = b
m.y = i
l.r = n
i.y = m
b.p = f
g.r = n
assert i.y.y.y.y.y.y.txt == "i"