class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = 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: B = None
        self.s: A = None
        self.v: B = None
        self.txt = txt

j = A("j")
n = B("n")
d = C("d")
g = A("g")
e = B("e")

j.o = g
j.t = d
n.s = d
d.w = n
d.s = g
d.v = e
g.o = j
g.t = d
e.s = d
assert d.w.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = 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: B = None
        self.s: A = None
        self.v: B = None
        self.txt = txt

j = A("j")
n = B("n")
d = C("d")
g = A("g")
e = B("e")

j.o = g
j.t = d
n.s = d
d.w = n
d.s = g
d.v = e
g.o = j
g.t = d
e.s = d
assert d.w.s.v.s.txt == "d"