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

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

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

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

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

l.r = b
l.o = b
l.p = a
l.t = g
c.o = e
b.r = i
a.x = c
i.r = b
i.o = h
i.p = a
i.t = g
e.o = c
h.r = l
g.r = h
g.o = h
g.p = a
g.t = l
f.o = e
assert a.x.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: C = None
        self.p: D = None
        self.t: A = None
        self.txt = txt

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

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

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

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

l.r = b
l.o = b
l.p = a
l.t = g
c.o = e
b.r = i
a.x = c
i.r = b
i.o = h
i.p = a
i.t = g
e.o = c
h.r = l
g.r = h
g.o = h
g.p = a
g.t = l
f.o = e
assert a.x.o.o.o.o.o.o.o.txt == "e"