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

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

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

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

j = A("j")
k = B("k")
g = C("g")
d = D("d")
c = D("c")
n = C("n")
a = B("a")

j.x = n
j.y = n
j.q = g
k.p = d
g.q = j
g.v = n
g.o = a
d.r = a
d.o = n
d.v = n
d.t = k
c.r = k
c.o = n
c.v = n
c.t = a
n.q = j
n.v = g
n.o = a
a.p = c
assert a.p.v.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: C = None
        self.q: C = None
        self.txt = txt

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

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

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

j = A("j")
k = B("k")
g = C("g")
d = D("d")
c = D("c")
n = C("n")
a = B("a")

j.x = n
j.y = n
j.q = g
k.p = d
g.q = j
g.v = n
g.o = a
d.r = a
d.o = n
d.v = n
d.t = k
c.r = k
c.o = n
c.v = n
c.t = a
n.q = j
n.v = g
n.o = a
a.p = c
assert a.p.v.q.q.q.txt == "j"