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

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

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

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

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

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

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

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

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

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

a.w = n
a.x = n
a.t = k
k.r = d
d.o = k
d.p = a
b.s = k
b.t = j
n.w = a
n.x = a
n.t = k
j.s = k
j.t = b
e.o = k
e.p = a
assert e.p.x.w.txt == "a"