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

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

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

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

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

a = A("a")
b = B("b")
h = C("h")
n = D("n")
c = E("c")
e = B("e")

a.r = h
b.r = c
b.x = c
b.o = h
h.v = n
h.q = c
n.u = e
n.p = b
c.r = a
c.x = a
c.v = e
e.r = c
e.x = c
e.o = h
assert n.p.r.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

a = A("a")
b = B("b")
h = C("h")
n = D("n")
c = E("c")
e = B("e")

a.r = h
b.r = c
b.x = c
b.o = h
h.v = n
h.q = c
n.u = e
n.p = b
c.r = a
c.x = a
c.v = e
e.r = c
e.x = c
e.o = h
assert n.p.r.r.r.q.txt == "c"