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

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

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

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

a = A("a")
d = B("d")
k = C("k")
n = D("n")
j = A("j")
g = C("g")
c = A("c")
i = C("i")
l = A("l")
h = B("h")

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

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

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

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

a = A("a")
d = B("d")
k = C("k")
n = D("n")
j = A("j")
g = C("g")
c = A("c")
i = C("i")
l = A("l")
h = B("h")

a.u = j
d.q = h
d.o = h
k.w = g
k.p = h
k.y = l
n.q = d
n.r = h
n.o = h
j.u = a
g.w = i
g.p = h
g.y = l
c.u = a
i.w = g
i.p = d
i.y = j
l.u = a
h.q = d
h.o = d
assert g.p.o.q.txt == "h"