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

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

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

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

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

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

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

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

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

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

g.y = l
g.r = i
g.q = a
d.p = a
l.o = h
l.u = g
l.s = g
l.x = d
k.s = c
k.y = g
k.r = l
k.u = h
a.o = i
a.u = i
a.s = h
a.x = d
h.y = l
h.r = i
h.q = a
i.y = l
i.r = h
i.q = a
b.p = a
c.s = k
c.y = h
c.r = l
c.u = i
assert h.y.o.r.y.o.r.txt == "i"