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

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

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

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

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

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

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

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

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

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

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