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

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

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

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

h = A("h")
g = B("g")
n = C("n")
a = D("a")
e = C("e")
i = D("i")
j = D("j")
f = B("f")

h.t = g
g.u = h
g.t = h
g.x = h
n.u = e
n.v = h
a.p = j
a.r = j
a.x = g
e.u = n
e.v = h
i.p = a
i.r = a
i.x = f
j.p = a
j.r = a
j.x = g
f.u = h
f.t = h
f.x = h
assert n.u.u.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
n = C("n")
a = D("a")
e = C("e")
i = D("i")
j = D("j")
f = B("f")

h.t = g
g.u = h
g.t = h
g.x = h
n.u = e
n.v = h
a.p = j
a.r = j
a.x = g
e.u = n
e.v = h
i.p = a
i.r = a
i.x = f
j.p = a
j.r = a
j.x = g
f.u = h
f.t = h
f.x = h
assert n.u.u.u.v.txt == "h"