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

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

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

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

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

h = A("h")
a = B("a")
l = C("l")
b = D("b")
c = E("c")
k = B("k")

h.x = c
a.v = h
a.y = h
a.x = l
a.t = c
l.y = h
l.z = k
l.r = c
b.q = k
b.p = c
b.x = a
c.p = b
k.v = h
k.y = h
k.x = l
k.t = c
assert l.r.p.x.y.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

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

h = A("h")
a = B("a")
l = C("l")
b = D("b")
c = E("c")
k = B("k")

h.x = c
a.v = h
a.y = h
a.x = l
a.t = c
l.y = h
l.z = k
l.r = c
b.q = k
b.p = c
b.x = a
c.p = b
k.v = h
k.y = h
k.x = l
k.t = c
assert l.r.p.x.y.x.p.txt == "b"