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

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

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

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

f = A("f")
j = B("j")
b = C("b")
n = D("n")
e = B("e")
k = A("k")
g = C("g")
a = A("a")
c = D("c")

f.p = k
f.q = c
j.p = b
j.q = g
j.v = n
b.s = j
b.r = n
b.w = g
b.q = g
n.x = j
n.y = g
n.r = c
e.p = g
e.q = b
e.v = n
k.p = a
k.q = c
g.s = j
g.r = c
g.w = b
g.q = b
a.p = f
a.q = n
c.x = j
c.y = b
c.r = n
assert c.y.r.x.p.r.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: D = None
        self.txt = txt

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

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

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

f = A("f")
j = B("j")
b = C("b")
n = D("n")
e = B("e")
k = A("k")
g = C("g")
a = A("a")
c = D("c")

f.p = k
f.q = c
j.p = b
j.q = g
j.v = n
b.s = j
b.r = n
b.w = g
b.q = g
n.x = j
n.y = g
n.r = c
e.p = g
e.q = b
e.v = n
k.p = a
k.q = c
g.s = j
g.r = c
g.w = b
g.q = b
a.p = f
a.q = n
c.x = j
c.y = b
c.r = n
assert c.y.r.x.p.r.x.p.txt == "b"