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

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

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

e = A("e")
n = B("n")
h = C("h")
i = C("i")
m = C("m")
d = C("d")
b = A("b")
j = C("j")
k = B("k")
c = B("c")

e.x = c
n.r = e
n.y = c
n.x = h
h.o = j
i.o = m
m.o = j
d.o = j
b.x = k
j.o = d
k.r = b
k.y = n
k.x = m
c.r = e
c.y = n
c.x = m
assert d.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

e = A("e")
n = B("n")
h = C("h")
i = C("i")
m = C("m")
d = C("d")
b = A("b")
j = C("j")
k = B("k")
c = B("c")

e.x = c
n.r = e
n.y = c
n.x = h
h.o = j
i.o = m
m.o = j
d.o = j
b.x = k
j.o = d
k.r = b
k.y = n
k.x = m
c.r = e
c.y = n
c.x = m
assert d.o.o.o.o.o.o.txt == "d"