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

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

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

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

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

a.x = c
a.y = c
a.p = b
a.o = k
k.p = b
j.w = m
j.r = a
j.p = n
j.t = b
b.y = a
b.o = k
b.u = j
g.p = b
c.x = a
c.y = a
c.p = b
c.o = n
m.w = j
m.r = c
m.p = k
m.t = b
n.p = b
assert n.p.u.t.y.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: D = None
        self.y: A = None
        self.o: B = None
        self.txt = txt

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

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

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

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

a.x = c
a.y = c
a.p = b
a.o = k
k.p = b
j.w = m
j.r = a
j.p = n
j.t = b
b.y = a
b.o = k
b.u = j
g.p = b
c.x = a
c.y = a
c.p = b
c.o = n
m.w = j
m.r = c
m.p = k
m.t = b
n.p = b
assert n.p.u.t.y.x.p.txt == "b"