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

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

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

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

i = A("i")
f = B("f")
j = C("j")
d = D("d")
k = A("k")
h = B("h")
e = A("e")
b = A("b")
c = C("c")

i.r = c
i.o = d
i.s = b
f.w = b
f.u = c
f.t = e
f.p = h
j.r = i
j.x = c
d.y = h
d.p = e
d.q = f
d.r = b
k.r = j
k.o = d
k.s = i
h.w = i
h.u = c
h.t = e
h.p = f
e.r = c
e.o = d
e.s = i
b.r = j
b.o = d
b.s = e
c.r = e
c.x = j
assert j.r.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: D = None
        self.s: A = None
        self.txt = txt

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

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

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

i = A("i")
f = B("f")
j = C("j")
d = D("d")
k = A("k")
h = B("h")
e = A("e")
b = A("b")
c = C("c")

i.r = c
i.o = d
i.s = b
f.w = b
f.u = c
f.t = e
f.p = h
j.r = i
j.x = c
d.y = h
d.p = e
d.q = f
d.r = b
k.r = j
k.o = d
k.s = i
h.w = i
h.u = c
h.t = e
h.p = f
e.r = c
e.o = d
e.s = i
b.r = j
b.o = d
b.s = e
c.r = e
c.x = j
assert j.r.s.o.txt == "d"