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

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

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

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

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

c = A("c")
g = B("g")
h = C("h")
d = D("d")
b = E("b")
j = C("j")

c.v = d
g.p = j
g.v = d
h.o = b
h.v = j
h.r = g
h.q = d
d.r = b
b.r = h
b.t = j
b.x = c
j.o = b
j.v = h
j.r = g
j.q = d
assert b.r.q.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

c = A("c")
g = B("g")
h = C("h")
d = D("d")
b = E("b")
j = C("j")

c.v = d
g.p = j
g.v = d
h.o = b
h.v = j
h.r = g
h.q = d
d.r = b
b.r = h
b.t = j
b.x = c
j.o = b
j.v = h
j.r = g
j.q = d
assert b.r.q.r.r.txt == "h"