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

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

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

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

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

g.o = e
g.y = j
f.y = a
f.q = e
n.o = j
a.r = e
a.w = e
a.o = f
a.v = g
e.r = a
e.w = a
e.o = f
e.v = h
j.o = b
b.o = j
h.o = a
h.y = n
assert h.y.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: C = None
        self.txt = txt

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

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

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

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

g.o = e
g.y = j
f.y = a
f.q = e
n.o = j
a.r = e
a.w = e
a.o = f
a.v = g
e.r = a
e.w = a
e.o = f
e.v = h
j.o = b
b.o = j
h.o = a
h.y = n
assert h.y.o.o.o.o.o.txt == "j"