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

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

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

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

g = A("g")
d = B("d")
f = C("f")
k = D("k")
e = B("e")
j = A("j")
b = C("b")
l = A("l")
n = C("n")
h = B("h")

g.o = l
g.x = d
d.u = g
d.r = f
d.w = f
d.p = f
f.v = e
k.x = h
e.u = l
e.r = b
e.w = n
e.p = f
j.o = l
j.x = d
b.v = d
l.o = g
l.x = d
n.v = d
h.u = l
h.r = f
h.w = b
h.p = n
assert j.o.o.x.u.o.x.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.x: B = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
f = C("f")
k = D("k")
e = B("e")
j = A("j")
b = C("b")
l = A("l")
n = C("n")
h = B("h")

g.o = l
g.x = d
d.u = g
d.r = f
d.w = f
d.p = f
f.v = e
k.x = h
e.u = l
e.r = b
e.w = n
e.p = f
j.o = l
j.x = d
b.v = d
l.o = g
l.x = d
n.v = d
h.u = l
h.r = f
h.w = b
h.p = n
assert j.o.o.x.u.o.x.u.x.u.txt == "g"