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

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

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

j = A("j")
a = B("a")
k = C("k")
g = B("g")
i = B("i")
l = C("l")
e = C("e")
c = A("c")
h = B("h")

j.p = i
a.x = c
k.s = l
g.x = c
i.x = c
l.s = e
e.s = l
c.p = h
h.x = j
assert g.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

j = A("j")
a = B("a")
k = C("k")
g = B("g")
i = B("i")
l = C("l")
e = C("e")
c = A("c")
h = B("h")

j.p = i
a.x = c
k.s = l
g.x = c
i.x = c
l.s = e
e.s = l
c.p = h
h.x = j
assert g.x.p.x.txt == "j"