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

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

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

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

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

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

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

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

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

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

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