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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: D = None
        self.p: A = None
        self.y: D = None
        self.txt = txt

b = A("b")
d = B("d")
g = C("g")
m = D("m")
l = C("l")
a = D("a")
i = B("i")

b.p = g
b.s = g
d.y = m
d.s = i
d.q = b
d.u = a
g.v = a
g.o = b
m.u = b
m.p = b
m.t = a
m.y = a
l.v = m
l.o = b
a.u = b
a.p = b
a.t = m
a.y = m
i.y = a
i.s = d
i.q = b
i.u = m
assert i.u.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: D = None
        self.p: A = None
        self.y: D = None
        self.txt = txt

b = A("b")
d = B("d")
g = C("g")
m = D("m")
l = C("l")
a = D("a")
i = B("i")

b.p = g
b.s = g
d.y = m
d.s = i
d.q = b
d.u = a
g.v = a
g.o = b
m.u = b
m.p = b
m.t = a
m.y = a
l.v = m
l.o = b
a.u = b
a.p = b
a.t = m
a.y = m
i.y = a
i.s = d
i.q = b
i.u = m
assert i.u.p.p.txt == "g"