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

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

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

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

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

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

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

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

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

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

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