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

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

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: D = None
        self.txt = txt

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

j = A("j")
k = B("k")
a = C("a")
f = D("f")
g = B("g")
h = C("h")
e = A("e")
c = C("c")

j.p = a
j.r = e
j.y = e
k.s = h
a.w = c
a.q = f
f.p = e
f.w = h
f.z = j
g.s = h
h.w = c
h.q = f
e.p = c
e.r = j
e.y = j
c.w = a
c.q = f
assert j.r.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: A = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: D = None
        self.txt = txt

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

j = A("j")
k = B("k")
a = C("a")
f = D("f")
g = B("g")
h = C("h")
e = A("e")
c = C("c")

j.p = a
j.r = e
j.y = e
k.s = h
a.w = c
a.q = f
f.p = e
f.w = h
f.z = j
g.s = h
h.w = c
h.q = f
e.p = c
e.r = j
e.y = j
c.w = a
c.q = f
assert j.r.y.r.y.txt == "j"