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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: A = None
        self.txt = txt

e = A("e")
g = B("g")
c = C("c")
m = D("m")
k = E("k")
h = B("h")
j = B("j")
f = B("f")
l = E("l")

e.x = c
g.p = h
c.y = g
c.p = e
c.x = e
c.r = m
c.v = j
m.u = h
k.v = m
k.q = e
h.p = g
j.p = g
f.p = h
l.v = m
l.q = e
assert e.x.y.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: A = None
        self.txt = txt

e = A("e")
g = B("g")
c = C("c")
m = D("m")
k = E("k")
h = B("h")
j = B("j")
f = B("f")
l = E("l")

e.x = c
g.p = h
c.y = g
c.p = e
c.x = e
c.r = m
c.v = j
m.u = h
k.v = m
k.q = e
h.p = g
j.p = g
f.p = h
l.v = m
l.q = e
assert e.x.y.p.p.p.p.p.txt == "h"