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

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

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

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

b = A("b")
n = B("n")
l = C("l")
j = D("j")
c = A("c")
k = C("k")
g = C("g")
a = A("a")
i = D("i")
d = B("d")

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

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

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

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

b = A("b")
n = B("n")
l = C("l")
j = D("j")
c = A("c")
k = C("k")
g = C("g")
a = A("a")
i = D("i")
d = B("d")

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