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

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: A = None
        self.txt = txt

g = A("g")
a = B("a")
c = C("c")
m = D("m")
l = C("l")
e = C("e")
h = A("h")

g.q = h
a.v = h
a.t = m
c.x = l
c.o = a
m.s = l
m.x = h
l.x = c
l.o = a
e.x = c
e.o = a
h.q = g
assert e.x.x.x.x.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: A = None
        self.txt = txt

g = A("g")
a = B("a")
c = C("c")
m = D("m")
l = C("l")
e = C("e")
h = A("h")

g.q = h
a.v = h
a.t = m
c.x = l
c.o = a
m.s = l
m.x = h
l.x = c
l.o = a
e.x = c
e.o = a
h.q = g
assert e.x.x.x.x.o.v.txt == "h"