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

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

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

class D:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: C = None
        self.q: C = None
        self.o: D = None
        self.txt = txt

h = A("h")
i = B("i")
n = C("n")
c = D("c")
l = A("l")
f = B("f")
k = D("k")
g = B("g")

h.o = l
i.v = n
i.t = n
i.y = n
i.o = c
n.o = l
c.p = k
c.o = k
c.s = n
c.q = n
l.o = h
f.v = n
f.t = n
f.y = n
f.o = k
k.p = c
k.o = c
k.s = n
k.q = n
g.v = n
g.t = n
g.y = n
g.o = c
assert c.o.q.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: C = None
        self.q: C = None
        self.o: D = None
        self.txt = txt

h = A("h")
i = B("i")
n = C("n")
c = D("c")
l = A("l")
f = B("f")
k = D("k")
g = B("g")

h.o = l
i.v = n
i.t = n
i.y = n
i.o = c
n.o = l
c.p = k
c.o = k
c.s = n
c.q = n
l.o = h
f.v = n
f.t = n
f.y = n
f.o = k
k.p = c
k.o = c
k.s = n
k.q = n
g.v = n
g.t = n
g.y = n
g.o = c
assert c.o.q.o.o.txt == "h"