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

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

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

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

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

l.o = n
d.r = b
d.x = e
d.t = e
d.v = l
n.x = i
n.p = e
b.x = l
f.x = l
i.x = l
e.x = i
e.p = n
g.r = i
g.x = n
g.v = l
g.t = e
m.x = l
assert g.r.x.o.x.x.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

l.o = n
d.r = b
d.x = e
d.t = e
d.v = l
n.x = i
n.p = e
b.x = l
f.x = l
i.x = l
e.x = i
e.p = n
g.r = i
g.x = n
g.v = l
g.t = e
m.x = l
assert g.r.x.o.x.x.o.p.txt == "e"