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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: D = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
b = C("b")
j = D("j")
d = E("d")
i = A("i")
h = A("h")
n = E("n")
c = E("c")
g = B("g")

a.r = j
e.s = i
e.y = j
b.p = c
j.v = c
j.u = c
j.q = a
d.q = c
d.v = c
d.p = n
i.r = j
h.r = j
n.q = c
n.p = c
n.v = c
c.q = d
c.v = d
c.p = n
g.s = h
g.y = j
assert i.r.q.r.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: D = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
b = C("b")
j = D("j")
d = E("d")
i = A("i")
h = A("h")
n = E("n")
c = E("c")
g = B("g")

a.r = j
e.s = i
e.y = j
b.p = c
j.v = c
j.u = c
j.q = a
d.q = c
d.v = c
d.p = n
i.r = j
h.r = j
n.q = c
n.p = c
n.v = c
c.q = d
c.v = d
c.p = n
g.s = h
g.y = j
assert i.r.q.r.q.r.txt == "j"