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

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

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

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

c = A("c")
h = B("h")
f = C("f")
k = D("k")
m = B("m")
b = D("b")
i = B("i")
n = A("n")
a = A("a")
g = A("g")

c.u = m
c.t = f
c.s = n
h.s = f
f.u = k
k.v = f
k.p = f
k.x = h
m.s = f
b.v = f
b.p = f
b.x = h
i.s = f
n.u = i
n.t = f
n.s = a
a.u = h
a.t = f
a.s = c
g.u = i
g.t = f
g.s = a
assert h.s.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: C = None
        self.s: A = None
        self.txt = txt

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

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

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

c = A("c")
h = B("h")
f = C("f")
k = D("k")
m = B("m")
b = D("b")
i = B("i")
n = A("n")
a = A("a")
g = A("g")

c.u = m
c.t = f
c.s = n
h.s = f
f.u = k
k.v = f
k.p = f
k.x = h
m.s = f
b.v = f
b.p = f
b.x = h
i.s = f
n.u = i
n.t = f
n.s = a
a.u = h
a.t = f
a.s = c
g.u = i
g.t = f
g.s = a
assert h.s.u.p.txt == "f"