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

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

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

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

l = A("l")
j = B("j")
c = C("c")
n = D("n")
h = D("h")
k = A("k")
m = B("m")
b = C("b")
g = D("g")

l.q = k
l.y = k
j.o = c
c.o = m
c.q = b
n.q = c
n.p = c
n.w = h
h.q = b
h.p = c
h.w = n
k.q = l
k.y = l
m.o = b
b.o = m
b.q = c
g.q = b
g.p = b
g.w = h
assert h.w.q.q.o.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.y: A = None
        self.txt = txt

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

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

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

l = A("l")
j = B("j")
c = C("c")
n = D("n")
h = D("h")
k = A("k")
m = B("m")
b = C("b")
g = D("g")

l.q = k
l.y = k
j.o = c
c.o = m
c.q = b
n.q = c
n.p = c
n.w = h
h.q = b
h.p = c
h.w = n
k.q = l
k.y = l
m.o = b
b.o = m
b.q = c
g.q = b
g.p = b
g.w = h
assert h.w.q.q.o.o.q.txt == "c"