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

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

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

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

g = A("g")
b = B("b")
d = C("d")
h = D("h")
f = A("f")
c = C("c")
a = B("a")
j = D("j")

g.r = b
g.s = b
g.y = j
g.q = a
b.o = g
b.z = g
b.x = f
d.r = j
d.x = j
d.p = b
h.u = d
h.o = f
h.x = f
h.t = b
f.r = a
f.q = a
f.s = a
f.y = h
c.r = h
c.x = h
c.p = a
a.o = f
a.z = g
a.x = g
j.u = c
j.o = g
j.x = f
j.t = b
assert c.r.u.p.x.y.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: D = None
        self.q: B = None
        self.s: B = None
        self.txt = txt

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

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

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

g = A("g")
b = B("b")
d = C("d")
h = D("h")
f = A("f")
c = C("c")
a = B("a")
j = D("j")

g.r = b
g.s = b
g.y = j
g.q = a
b.o = g
b.z = g
b.x = f
d.r = j
d.x = j
d.p = b
h.u = d
h.o = f
h.x = f
h.t = b
f.r = a
f.q = a
f.s = a
f.y = h
c.r = h
c.x = h
c.p = a
a.o = f
a.z = g
a.x = g
j.u = c
j.o = g
j.x = f
j.t = b
assert c.r.u.p.x.y.u.p.txt == "b"