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

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

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

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

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

k.p = c
k.t = c
k.o = a
e.u = k
e.w = b
d.w = b
d.p = b
n.q = a
n.x = k
j.p = c
j.t = c
j.o = n
b.w = d
b.p = d
a.q = n
a.x = k
c.p = k
c.o = a
c.t = j
assert b.p.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: D = None
        self.t: A = None
        self.txt = txt

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

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

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

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

k.p = c
k.t = c
k.o = a
e.u = k
e.w = b
d.w = b
d.p = b
n.q = a
n.x = k
j.p = c
j.t = c
j.o = n
b.w = d
b.p = d
a.q = n
a.x = k
c.p = k
c.o = a
c.t = j
assert b.p.p.w.p.txt == "b"