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

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

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

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

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

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

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

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

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

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

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